from torch import nn
import torch as t

def get_l2(model):
    l2_list = []
    for layer in model.modules():
        if isinstance(layer, nn.Conv2d):
            l2_list.append(t.sum(t.pow(layer.weight.data, 2)))
    return l2_list